﻿@using Masa.Blazor.Presets

<div class="text-center">
    <PMobileTimePicker @bind-Value="_time" Formatter="@CustomFormatter">
        <ActivatorContent>
            <MButton Color="primary" Class="text-capitalize" Text @attributes="@context.Attrs">
                @_time.ToString("HH:mm:ss")
            </MButton>
        </ActivatorContent>
    </PMobileTimePicker>
</div>

@code {

    private TimeOnly _time;

    private static string CustomFormatter(TimePrecision type, int val)
    {
        return type switch 
        {
            TimePrecision.Hour => $"{val}时",
            TimePrecision.Minute => $"{val}分",
            TimePrecision.Second => $"{val}秒",
            _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
        };
    }

}
